<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>优惠商家</title>
<link href="${pageContext.request.contextPath}/home/css/css.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/home/js/jquery.tools.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/home/js/shangjia_dialog.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/home/js/Ajax.class.js"></script>
<script type="text/javascript">
function createPagenation(rowsCount, onePageRows, currentPage) {
	var pagesCount = parseInt(rowsCount%onePageRows==0?rowsCount/onePageRows:(rowsCount/onePageRows+1));
	if(pagesCount<2)return;
	var str = '';
	if(currentPage>1){
		str = '<li><a class="page_nav_prev" href="javascript:;" onclick="getPage('+(currentPage-1)+');">&lt;上一页</a></li>';
	}
	var index = 1;
	var count = 10;
	if (pagesCount>10&&(currentPage-4>0)) {
		index = currentPage-4;
	}
	if ((currentPage+5)>pagesCount) {
		count = pagesCount;
	} else {
		count = currentPage+5;
	}
	count = count < 10 ? 10 : count;
	for (var i=index; i <= count; i++) {
		if (i == currentPage)
			str += '<li class="page_nav_current">'+i+'</li>';
		else
			str += '<li><a href="javascript:;" onclick="getPage('+i+');">'+i+'</a></li>';
	}
	if(currentPage<pagesCount){
		str += '<li><a class="page_nav_next" href="javascript:;" onclick="getPage('+(currentPage+1)+');">下一页&gt;</a></li>';
	}
	if (str != '')
		$(str).appendTo($("#ul_pagenation"));
}
function getPage(page){
	$("input[name='page']").val(page);
	$("#pageForm").submit();
}
function getCustomer(){
	var temp = $(Ajax.getObject());
	var id = temp.find("ID").text();
	var PicName = temp.find("PicName").text();
	var introduce = temp.find("Introduce").text();
	var memberBenefits = temp.find("MemberBenefits").text();
	var fontStr = "<font style='padding-left:26px'></font>";
	$("#customer_img").attr("src", "${pageContext.request.contextPath}/upload/images/customer/"+id+"/"+PicName);
	$("#customer_introduce").html(fontStr+introduce);
	$("#customer_memberBenefits").html(fontStr+memberBenefits);
	showDialog();
}
</script>
</head>
<body>
<!-- 头部开始 -->
<jsp:include page="/home/top.jsp?current=shangjia"></jsp:include>
<!-- 头部结束 -->
<!--优惠商家开始-->
<div style="width:100%;text-align:center; background:#C2C2C2; padding-top:25px">
	<div style="width:800px;text-align:left">
	<div style="background:#F6F6F6; padding:20px 0 0px 0px;">
		<div style="width:100%; padding-left:20px; padding-bottom:2px">
			<table cellpadding="0" cellspacing="0" height="33px">
				<tr>
					<td width="189px" height="33px" background="${pageContext.request.contextPath}/home/images/yh_customer.jpg" style="background-repeat:no-repeat"></td>
					<td width="570px" align="right" valign="middle">
						<div style="font-weight:bold; color: #9B9B9B; font-size:18px">更多优惠商家请下载一卡手机客户端</div>
					</td>
				</tr></table>
		</div>
		<div style="width:100%; height:2px; background-color:#00AD00;"></div>
		<div style="padding-top:30px;">
			<table cellpadding="0" cellspacing="0" align="center">
				<c:forEach items="${customerList}" var="customer" varStatus="i">
				<c:if test="${i.index==0||(i.index%4==0)}"><tr style="height: 160px"></c:if>
				<td width="195px" align="center"><a href="javascript:;" onclick="Ajax.get('${pageContext.request.contextPath}/webManager/getCustomer.action?id=${customer.id}', 'xml', getCustomer);"><img src="${pageContext.request.contextPath}/upload/images/customer/${customer.id}/${customer.picName}" width="173px" height="117px"/></a><div style="height: 20px"></div><a href="javascript:;" onclick="Ajax.get('${pageContext.request.contextPath}/webManager/getCustomer.action?id=${customer.id}', 'xml', getCustomer);">${customer.name}</a></td>
				<c:if test="${(i.index+1)%4==0 || ((i.index+1)==fn:length(customerList))}"></tr></c:if>
				</c:forEach>
				<tr height="20px"></tr>
			</table>
		</div>
		<!--分页开始-->
		<div class="page_nav" id="page_nav">
			<ul id="ul_pagenation"></ul>
		</div>
<!--分页结束-->
	</div>
	</div>
	<div style="height:35px"></div>
</div>
<!--优惠商家结束-->
<!--底部开始-->
<jsp:include flush="true" page="/home/bottom.jsp"></jsp:include>
<!--底部结束-->
<div id="zhegai" style="position:absolute;background-color:#eee;top:0;left:0;filter:alpha(opacity=50);opacity:0.5; display:none"></div>
<div id="dialogDiv" style="width:780px; height:550px; border:3px solid #00AD00;font-size:14px; color:#030303;position:absolute; left:238px; top:200px; display:none">
		<div style="background-color:#FAFAFA;height:34px; text-align:right"><a id="closeA" href="javascript:;" onclick="closeDialog();"><img src="${pageContext.request.contextPath}/home/images/yh_customer_detail_close.jpg"/></a></div>
		<div style="padding:0px 45px 10px 20px; height:156px;background-color:#FAFAFA;">
		<table cellpadding="0" cellspacing="0" height="156px">
			<tr valign="middle">
				<td width="210px"><img id="customer_img" width="173px" height="117px"/></td>
				<td><div id="customer_introduce" style="line-height:20px;font-size:13px"></div></td>
			</tr></table>
	</div>
	<div style="width:100%; height:1px; background-color:#00AD00;"></div>
	<div style="background-color:#DCF8DC; padding:20px 0px 10px 0px; height:319px">
		<div style="text-align:center;">
		<div style="background-image:url(${pageContext.request.contextPath}/home/images/yh_customer_detail.jpg); background-repeat:no-repeat; height:42px; width:185px"></div>
		</div>
		<div id="customer_memberBenefits" style="padding:20px 50px 0px 50px; line-height:20px;font-size:13px"></div>
	</div>
</div>
<form id="pageForm" action="${pageContext.request.contextPath}/webManager/customerList.action"><input name="page" type="hidden"/></form>
<script type="text/javascript">createPagenation(parseInt("${paginator.totalCount}"),parseInt("${paginator.pageSize}"),parseInt("${paginator.pageIndex}"));</script>
</body>
</html>